import config from "@/config"
import http from "@/utils/request"



export default {
  getShiftList: {
    url: `${config.API_URL}/attendanceArrange/list`,
    name: "获取考勤班次列表",
    get: function (data = {}) {
      return new Promise((resolve, reject) => {
        http.get(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  getShiftDetail: {
    url: `${config.API_URL}/attendanceArrange/seeDetails`,
    name: "获取考勤班次详情",
    post: function (data = {}) {
      return new Promise((resolve, reject) => {
        http.postParam(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },


  addshift: {
    url: `${config.API_URL}/attendanceArrange/add`,
    name: "添加考勤班次",
    post: function (data = {}) {
      return new Promise((resolve, reject) => {
        http.post(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  updateShift: {
    url: `${config.API_URL}/attendanceArrange/update`,
    name: "修改考勤班次",
    post: function (data = {}) {
      return new Promise((resolve, reject) => {
        http.post(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  deleteShift: {
    url: `${config.API_URL}/attendanceArrange/delete`,
    name: "删除考勤班次",
    post: function (data = {}) {
      return new Promise((resolve, reject) => {
        http.postParam(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },


  getAttendanceLocations: {
    url: `${config.API_URL}/arrangePoints/list`,
    name: "获取考勤点列表",
    get: function (data = {}) {
      return new Promise((resolve, reject) => {
        http.get(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  addAttendanceLocation: {
    url: `${config.API_URL}/arrangePoints/add`,
    name: "添加考勤点",
    post: function (data = {}) {
      return new Promise((resolve, reject) => {
        http.post(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  updateAttendanceLocation: {
    url: `${config.API_URL}/arrangePoints/update`,
    name: "修改考勤点",
    post: function (data = {}) {
      return new Promise((resolve, reject) => {
        http.post(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  deleteAttendanceLocation: {
    url: `${config.API_URL}/arrangePoints/delete`,
    name: "删除考勤点",
    post: function (data = {}) {
      return new Promise((resolve, reject) => {
        http.postParam(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  getAttendanceList: {
    url: `${config.API_URL}/attendance/getAttendList`,
    name: "获取考勤统计列表（月统计）",
    get: function (data = {}) {
      return new Promise((resolve, reject) => {
        http.get(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },
  getAttendanceItem: {
    url: `${config.API_URL}/attendance/list`,
    name: "获取用户考勤列表",
    post: function (data = {}) {
      return new Promise((resolve, reject) => {
        http.postParam(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  getUserClockIn: {
    url: `${config.API_URL}/attendance/showDetails`,
    name: "获取用户某天打卡详细信息",
    post: function (data = {}) {
      return new Promise((resolve, reject) => {
        http.postParam(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },
  exportAttendanceList: {
    url: `${config.API_URL}/attendance/export`,
    name: "导出考勤统计",
    get: function (data = {}) {
      return new Promise((resolve, reject) => {
        http.get(this.url, data, { responseType: 'blob', }).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },
  exportAttendanceItem: {
    url: `${config.API_URL}/attendance/exportList`,
    name: "导出考勤个人详情列表",
    get: function (data = {}) {
      return new Promise((resolve, reject) => {
        http.get(this.url, data, { responseType: 'blob', }).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  // 请假管理
  getAskForLeaveList: {
    url: `${config.API_URL}/attendanceLeave/list`,
    name: "获取请假列表",
    get: function (data = {}) {
      return new Promise((resolve, reject) => {
        http.get(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },
  getAskForLeaveDetail: {
    url: `${config.API_URL}/attendanceLeave/detail`,
    name: "获取请假详情",
    post: function (data = {}) {
      return new Promise((resolve, reject) => {
        http.postParam(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },
}
